Skip to content

Migrate Package Source Mapping tests#7308

Open
nkolev92 wants to merge 12 commits intodevfrom
dev-nkolev92-migratePSMTests
Open

Migrate Package Source Mapping tests#7308
nkolev92 wants to merge 12 commits intodevfrom
dev-nkolev92-migratePSMTests

Conversation

@nkolev92
Copy link
Copy Markdown
Member

@nkolev92 nkolev92 commented Apr 20, 2026

Bug

Fixes: NuGet/Home#12185

Description

Migrates PowerShell E2E tests from PackageNameSpaceTests.ps1 to C# Apex tests. The feature was renamed from "PackageNameSpace" to "PackageSourceMapping", so new test names reflect the current terminology.

PackageNameSpaceTests.ps1 is now fully migrated — all test functions have been ported to Apex or deleted as duplicates.

Migration decisions

# PS Test Function Decision Apex Target Notes
1 Test-PackageSourceMappingRestore-WithSingleFeed Migrate NuGetConsoleTestCase.RestorePackageForPC_PackageSourceMapping_WithSingleFeed Restore-on-build test: manually writes packages.config, builds via SolutionService.Build().
2 Test-PackageSourceMappingRestore-WithMultipleFeedsWithIdenticalPackages-RestoresCorrectPackage Migrate NuGetConsoleTestCase.RestorePackageForPC_PackageSourceMapping_WithMultipleFeedsWithIdenticalPackages_RestoresCorrectPackage Same restore-on-build pattern as #1 with two feeds and content-file verification.
3 Test-VsPackageInstallerServices-PackageSourceMappingInstall-WithSingleFeed-Succeed Delete (already covered) IVsServicesTestCase.SimpleInstallFromIVsInstaller_PackageSourceMapping_WithSingleFeed Existing Apex test covers the same scenario.
4 Test-VsPackageInstallerServices-PackageSourceMappingInstall-WithSingleFeed-Fails Migrate IVsServicesTestCase.SimpleInstallFromIVsInstaller_PackageSourceMapping_WithMissingMappedSource_Fails Error-path: maps pattern to non-existent source, asserts package NOT installed.
5 Test-VsPackageInstallerServices-PackageSourceMappingInstall-WithMultipleFeedsWithIdenticalPackages-RestoresCorrectPackageWithSpecifiedVersion Delete (already covered) IVsServicesTestCase.SimpleInstallFromIVsInstaller_PackageSourceMapping_WithMultipleFeedsWithIdenticalPackages_InstallsCorrectPackage Existing Apex test covers specified-version install with content file verification.
6 Test-VsPackageInstallerServices-PackageSourceMappingInstall-WithMultipleFeedsWithIdenticalPackages-RestoresCorrectPackageWithLatestVersion Migrate IVsServicesTestCase.SimpleInstallLatestFromIVsInstaller_PackageSourceMapping_WithMultipleFeedsWithIdenticalPackages_InstallsCorrectPackage Latest-version (no version specified) install from mapped source, verifying correct feed via content file.
7 Test-PC-PackageSourceMappingInstall-Succeed Delete (already covered) NuGetConsoleTestCase.InstallPackageForPC_PackageSourceMapping_WithSingleFeed Existing Apex test covers single-feed PMC install.
8 Test-PC-PackageSourceMappingInstall-Fails Migrate NuGetConsoleTestCase.InstallPackageForPC_PackageSourceMapping_WithWrongMappedFeed_Fails Error-path: two feeds, pattern mapped to wrong feed, asserts PMC error message.
9 Test-PC-PackageSourceMappingInstall-WithCorrectSourceOption-Succeed Migrate NuGetConsoleTestCase.InstallPackageForPC_PackageSourceMapping_WithCorrectSourceOption_InstallsCorrectPackage Uses -Source to install from mapped private feed, verifies content file origin.
10 Test-PC-PackageSourceMappingInstall-WithWrongSourceOption-Fails Migrate NuGetConsoleTestCase.InstallPackageForPC_PackageSourceMapping_WithWrongSourceOption_Fails Error-path: -Source points to unmapped feed, asserts PMC error message.
11 Test-PC-PackageSourceMappingUpdate-WithCorrectSourceOption-Succeed Migrate NuGetConsoleTestCase.UpdatePackageForPC_PackageSourceMapping_WithCorrectSourceOption_UpdatesCorrectPackage Install v1 then update to v2 from mapped source, verifies content file origin.

File changes

  • NuGetConsoleTestCase.cs — 6 new PMC tests (tests 1, 2, 8, 9, 10, 11); added SaveAll() after package operations to prevent save dialog
  • IVsServicesTestCase.cs — 2 new IVs API tests (tests 4, 6); added SaveAll() after package operations
  • VisualStudioHostExtension.cs — Fixed flaky ClearErrorWindow by catching OperationCanceledException (UI thread contention during best-effort cleanup)
  • PackageNameSpaceTests.ps1 — Fully migrated: all test functions removed
  • SKILL.md — Updated Apex migration skill with learnings

PR Checklist

  • Meaningful title, helpful description and a linked NuGet/Home issue
  • Added tests
  • Link to an issue or pull request to update docs if this PR changes settings, environment variables, new feature, etc.

nkolev92 and others added 2 commits April 20, 2026 14:33
Replaced CreateConfigurationFile with Settings.AddSource() and
Settings.AddPackageSourceMapping() in 4 PMC source mapping tests to
preserve SimpleTestPathContext defaults (globalPackagesFolder, etc.).
Also reuse the default 'source' feed as the opensource repo where possible.

Updated apex-migration skill with config gotcha learning.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment thread test/NuGet.Tests.Apex/NuGet.Tests.Apex/NuGetEndToEndTests/NuGetConsoleTestCase.cs Outdated
Comment thread test/NuGet.Tests.Apex/NuGet.Tests.Apex/NuGetEndToEndTests/NuGetConsoleTestCase.cs Outdated
nkolev92 and others added 5 commits April 22, 2026 19:08
…pleTestPathContext

- Migrate 2 PS PackageNameSpaceTests (restore with source mapping) to Apex
- Fix 6 NuGetConsoleTestCase tests to use SimpleTestPathContext APIs instead of CreateConfigurationFile
- Remove migrated PS functions and CreateCustomTestPackage helper

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@nkolev92 nkolev92 marked this pull request as ready for review April 24, 2026 22:57
@nkolev92 nkolev92 requested a review from a team as a code owner April 24, 2026 22:57
nkolev92 and others added 2 commits April 24, 2026 16:31
The tests were writing packages.config manually via File.WriteAllText which
the VS project system never detected. Now they install via PMC so the project
system is aware, then delete both PackagesV2 and UserPackagesFolder to force
restore to re-download from the mapped source during build.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants